<template>
  <div class="index">
    <div class="formBox">
        <p class="item"><span class="name">信仰名称 ：</span><input v-model="date.name" class="slong" placeholder="请输入内容"></input></p>
        <p class="item"><span class="name">详细信息 ：</span>
            <input v-model="date.detail" value="" class="slong" placeholder="请输入内容"></input>
        </p>
        <p class="item inputBox">
          <button @click="submit" class="submitInput">确定</button>
          <button @click="empty" class="emptyInput">重置</button>
        </p>
    </div>
    
  </div>
</template>
<script>
import Vue from 'vue'
import axios from 'axios'
import { Get, Post ,Put ,Delete} from '@/config/api'

export default {
  name: 'index',
  data() {
    return {
        list:[],
        listId:'',
        last:1,//顶级分类
        date:{
          name:'',
          detail:''
        }
    }
  },
  methods: {
    async submit() {
        this.$store.dispatch("loadOpen");
        let that=this
        let data={
            "name":this.date.name,
            "detail":this.date.detail
        };
        await Post('/base/faith',this.$store.state.token,data).then((reg)=>{
          this.$store.dispatch("loadClose")
          this.$router.push('/spanFaithList')
        }).catch(function(err){
          alert(err.data.message);
          this.$store.dispatch("loadClose");
        }.bind(this))
        
    },
    //清空信息
    empty() {
      for(var key in this.date){
        this.date[key]=''
      }
    },

  }
}

</script>
